"use strict"

async function resetCardHeight(parent,child){
    await Helper.sleep(1000);

    var container = $(parent)
    for(var ii=0;ii<container.length;ii++){
        var mycard2 = $(container[ii]).find(child);
        var maxHeight = 0;
        for(var jj=0;jj<mycard2.length;jj++){
            var outerHeight = $(mycard2[jj]).outerHeight();
            maxHeight = outerHeight > maxHeight ? outerHeight:maxHeight;
        }
        for(var jj=0;jj<mycard2.length;jj++){
            if($(mycard2[jj]).outerHeight()!=maxHeight){
                $(mycard2[jj]).outerHeight(maxHeight);
            }
        }
    }
}

function onLogin()
{
    Countdown();
    ShowRunes();
}

async function Countdown(){
    while(true){
        var value = await GetVOOKProgress();

        SetProgressBar(value + "%");

        await Helper.sleep(10000);
    }
}

async function SetProgressBar(value)
{
    $(".progress-bar").outerWidth(value)
    $(".progress-value").html(value)

}

async function Refresh()
{


}



let onComingsoon_ii = 0
function onComingsoon()
{
    if(onComingsoon_ii%2==1){
        toastr.info("Coming soon.", "", {
            positionClass: "toast-top-center",
            timeOut: 5e3,
            closeButton: !0,
            debug: !1,
            newestOnTop: !0,
            progressBar: !0,
            preventDuplicates: !0,
            onclick: null,
            showDuration: "300",
            hideDuration: "1000",
            extendedTimeOut: "1000",
            showEasing: "swing",
            hideEasing: "linear",
            showMethod: "fadeIn",
            hideMethod: "fadeOut",
            tapToDismiss: !1
        })
    }
    else{
        toastr.error("Coming soon..", "", {
            positionClass: "toast-top-center",
            timeOut: 5e3,
            closeButton: !0,
            debug: !1,
            newestOnTop: !0,
            progressBar: !0,
            preventDuplicates: !0,
            onclick: null,
            showDuration: "300",
            hideDuration: "1000",
            extendedTimeOut: "1000",
            showEasing: "swing",
            hideEasing: "linear",
            showMethod: "fadeIn",
            hideMethod: "fadeOut",
            tapToDismiss: !1
        })
    }

}

let RunesAll  = null;
async function ShowRunes()
{
    $.ajax({
        url: Helper.GetServerIP() + "/RunesAll",
                  dataType: "text",
                  type: "post",
                  data: { address: Helper.addressCur, offset: 0,count: 12 },
                  success: function (data) {
                    
                        // 删除之前的数据
                        var runes_list = $(".runes-list")[0];
                        for (var i = runes_list.children.length - 1; i >= 0; i--) {
                            runes_list.children[i].remove();
                        }

                        RunesAll = JSON.parse(data);

                        for(var ii=0;ii<RunesAll.length;ii++)
                        {
                            var item = JSON.parse(RunesAll[ii]);
                            search_insert( runes_list, item.Data, item.Number, item.ID, getDateDiff(item.Created), onclickitem);
                        }

                  },
                  error: function (err) {
                    ShowToastrError("Error",err.responseText);
                  }
      });


}


(function($) {
    "use strict"

    // 对齐背景
    resetCardHeight(".container-fluid",".profile-statistics");
    resetCardHeight(".container-fluid",".profile-statistics2");

    jQuery(window).on('resize',function(){
        resetCardHeight(".container-fluid",".profile-statistics");
        resetCardHeight(".container-fluid",".profile-statistics2");
    });

    Refresh();

})(jQuery);


